package org.swirrel.listener;

import java.awt.event.InputMethodEvent;
import org.swirrel.util.SwirrelException;
import org.swirrel.util.MethodCall;
import java.awt.event.InputMethodListener;

/**
 * <p>Title: Swirrel</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2009</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 0.1
 */
public class SwirrelInputMethodListener extends AbstractSwirrelListener implements InputMethodListener {

    private final MethodCall caretPositionChangedCall;
    private final MethodCall inputMethodTextChangedCall;

    public SwirrelInputMethodListener(MethodCall caretPositionChangedCall, MethodCall
        inputMethodTextChangedCall) {
        this.caretPositionChangedCall = caretPositionChangedCall;
        this.inputMethodTextChangedCall = inputMethodTextChangedCall;
        if(! checkSignature(caretPositionChangedCall, InputMethodEvent.class)) {
            throw new SwirrelException("Method must have none or one CaretEvent argument");
        }
    }

  public void inputMethodTextChanged(InputMethodEvent event) {
    call(inputMethodTextChangedCall, event);
  }

  public void caretPositionChanged(InputMethodEvent event) {
     call(caretPositionChangedCall, event);
  }
}
